package com.esunny.springboot.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局复用方法
 */
public class GlobalReuseMethod {
    /**
     * 从请求中获取属性
     */

    public static Object getAttribute(String attribute) {
        //从请求中拿出存放的个人信息
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
                .getRequestAttributes()).getRequest();
        return request.getAttribute(attribute);
    }
}
